home *** CD-ROM | disk | FTP | other *** search
- #!/usr/local/bin/tclsh
-
- proc FindExec { what } {
- set error [catch "exec whereis $what" path]
- if {$error || [llength $path] == 1} {
- Blurb "I can't seem to find out where $what is, please tell me:" 0
- set ret_path [GetPath $what]
- } else {
- if {[llength $path] > 2} {
- Blurb "I found $what at [expr [llength $path] - 1] different \
- places, please tell me which one you want." 0
- Blurb "" 0
- set temp [lrange $path 1 end]
- set count 1
- foreach item $temp {
- Blurb "$count. $item" 3
- incr count
- }
- set which "dummy"
- while {[catch "expr $which + 1"] || $which != [expr int($which)] \
- || $which < 0 || $which > [llength $temp]} {
- puts -nonewline "\nWhich? "
- gets stdin which
- }
- set ret_path [lindex $temp [expr $which - 1]]
- } else {
- set ret_path [lindex $path 1]
- Blurb "I found $what at $ret_path." 0
- puts -nonewline "\nIs that okay (y/n)? "
- gets stdin okay
- if {$okay != "y"} {
- set ret_path [GetPath $what]
- }
- }
- Blurb "" 0
- Blurb "Okay, we'll use the $what in $ret_path." 0
- }
- return $ret_path
- }
-
- proc GetPath { what } {
- set error 1
- while {$error} {
- Blurb "" 0
- Blurb "I see, you don't like that $what...okay, which one \
- would you like to use?" 0
- puts -nonewline "\nWhere? "
- gets stdin path
- Blurb "" 0
- Blurb "" 0
- set error 0
- if {[file exists $path]} {
- Blurb "Okay, I see, there is a $what at $path." 0
- } else {
- Blurb "Oops, I don't see a $what at $path." 0
- set error 1
- }
- if {[file executable $path]} {
- Blurb "Good, $path is also executable." 0
- } else {
- Blurb "Uh-oh, $path isn't executable." 0
- set error 1
- }
- if {$error} {
- Blurb "" 0
- Blurb "There seemed to have been a problem, do you want \
- to use that $path anyway?" 0
- puts -nonewline "\nOkay (y/n)? "
- gets stdin temp
- if {$temp == "y"} {
- set error 0
- }
- }
- }
- return $path
- }
-
- proc Blurb { message indent } {
- if {![catch {set size [exec stty size]}]} {
- # if the stty command worked
- set columns [lindex $size 1]
- } else {
- set columns 80
- }
- # a little margin for readability
- incr columns -2
- set line ""
- set space ""
- for {set i 0} {$i < abs($indent)} {incr i} {
- # generate the string of spaces for indention
- set space "$space "
- }
- foreach word $message {
- if {[string length $line] + [string length $word] < $columns} {
- set line "$line$word "
- } else {
- puts $line
- set line "$space$word "
- }
- }
- puts $line
- }
-
-
-
-
- Blurb "This script will ask you for some information and then install \
- OmniMoni accordingly. Note that this script is not particularly \
- robust regarding error checking, so please don't try to break it." 0
- Blurb "" 0
- Blurb "" 0
- Blurb "Which of these would you like to do?" 0
- Blurb "" 0
- Blurb "1. Do a real installation, quietly. This assumes wish is in \
- /usr/local/bin and will install the binary in \
- /usr/local/bin and support files in /usr/local/lib/omnimoni and the \
- man page in /usr/local/man/man1/omnimoni.1." 4
- Blurb "2. Do a real installation, verbosely." 4
- Blurb "3. Just find out what would be copied where if I was doing a real \
- installation." 3
- puts -nonewline "\nType: "
- gets stdin type
- if {$type == 1} {
- set VERBOSE 0
- set INSTALL 1
- } elseif {$type == 2} {
- set VERBOSE 1
- set INSTALL 1
- } else {
- set VERBOSE 1
- set INSTALL 0
- set type 3
- }
-
- set wish_path "/usr/local/bin/wish"
- if {$VERBOSE} {
- Blurb "" 0
- Blurb "" 0
- Blurb "Okay then, we will do a type $type installation. Now I'm going to \
- try to figure out some stuff about your system and ask you to \
- verify it. If you enter any directories, they can not be local \
- to here and they can not use any special characters like ~ \
- (tilde)." 0
- Blurb "" 0
- Blurb "" 0
- set wish_path [FindExec wish]
- }
-
-
- set bin_path ""
- if {$VERBOSE} {
- Blurb "" 0
- Blurb "" 0
- Blurb "Next I need to know where to install the OmniMoni executable. \
- I'll create the directory and the path above it if either don't \
- exist." 0
- puts -nonewline "\nWhere \[/usr/local/bin\]? "
- gets stdin bin_path
- }
- if {$bin_path == ""} {
- set bin_path "/usr/local/bin"
- }
-
- set pics "both"
- if {$VERBOSE} {
- Blurb "" 0
- Blurb "" 0
- Blurb "Next I need to know if you want to install the support files. \
- They are two GIF pictures and are 100% \
- unnecessary and fluff. If you don't want them everything will \
- still work just fine. They are about 95k and 10k." 0
- Blurb "" 0
- Blurb "1. I want both because I like beautifully ray-traced pictures to \
- show up when OmniMoni starts and to entertain me if a window is \
- otherwise empty." 3
- Blurb "2. I just want the big one." 3
- Blurb "3. I just want the little one." 3
- Blurb "4. I don't want any of 'em." 3
- unset pics
- puts -nonewline "\nWhich? "
- gets stdin which
- if {$which == 1} {
- set pics "both"
- } elseif {$which == 2} {
- set pics "big"
- } elseif {$which == 3} {
- set pics "small"
- } else {
- set pics "none"
- }
- }
-
- set lib_path "/usr/local/lib/omnimoni"
- if {$VERBOSE} {
- if {$pics != "none"} {
- Blurb "" 0
- Blurb "" 0
- Blurb "Great, you choose to go wild and have useless graphics! Now, \
- where do you want this amazing artwork to go? Again, I'll \
- create the path if I need to." 0
- puts -nonewline "\nWhere \[/usr/local/lib/omnimoni\]? "
- gets stdin lib_path
- if {$lib_path == ""} {
- set lib_path "/usr/local/lib/omnimoni"
- }
- if {$lib_path != "/usr/local/lib/omnimoni"} {
- Blurb "" 0
- Blurb "Because you did not put the support files at the default \
- place I will create a small script file called \
- \"omnimoni\" which I will put in the binary directory. \
- This script will set the environmental variable \
- OMNIMONI_LIB to $lib_path and then call real omnimoni." 0
- }
- }
- }
-
- set man_path "[file dirname $bin_path]/man"
- if {$VERBOSE} {
- Blurb "" 0
- Blurb "" 0
- Blurb "Almost done here, the last thing is where to put the man file. \
- I'll take a guess and say you want it at $man_path." 0
- puts -nonewline "\nCorrect (y/n)? "
- gets stdin okay
- if {$okay != "y"} {
- Blurb "" 0
- Blurb "Okay then, where do you want the man file?" 0
- puts -nonewline "\nWhere? "
- gets stdin man_path
- }
- }
-
- if {$VERBOSE} {
- Blurb "" 0
- Blurb "" 0
- Blurb "" 0
- Blurb "" 0
- Blurb "Here we go..." 0
- Blurb "" 0
- Blurb "Updating file to reflect path changes..." 0
- }
- if {$INSTALL} {
- if {$lib_path != "/usr/local/lib/omnimoni"} {
- exec echo "\#!/bin/sh" > /tmp/omnimoni
- exec echo "OMNIMONI_LIB=$lib_path" >> /tmp/omnimoni
- exec echo "export OMNIMONI_LIB" >> /tmp/omnimoni
- exec echo "$lib_path/omnimoni.tcl" >> /tmp/omnimoni
- exec echo "\#!$wish_path -f" > /tmp/omnimoni.tcl
- exec cat src/omnimoni.tcl >> /tmp/omnimoni.tcl
- exec install -d -m 755 $lib_path
- exec install -m 555 /tmp/omnimoni.tcl $lib_path
- } else {
- exec echo "\#!$wish_path -f" > /tmp/omnimoni
- exec cat src/omnimoni.tcl >> /tmp/omnimoni
- }
- }
- if {$VERBOSE} {
- Blurb "Copying OmniMoni to $bin_path/omnimoni with 555 \
- permissions..." 0
- }
- if {$INSTALL} {
- exec install -d -m 755 $bin_path
- exec install -m 555 /tmp/omnimoni $bin_path
- exec cp man/omnimoni.man.part1 /tmp/omnimoni.1
- }
- if {$VERBOSE} {
- Blurb "Copying omnimoni.1 to $man_path/omnimoni.1 with 444 \
- permissions..." 0
- }
- if {$pics != "none"} {
- if {$VERBOSE} {
- Blurb "Copying $pics artwork to $lib_path with 444 permissions..." 0
- }
- if {$INSTALL} {
- if {$pics == "both"} {
- exec install -d -m 755 $lib_path
- exec install -m 444 pics/omnimoni.big.gif $lib_path
- exec install -m 444 pics/omnimoni.small.gif $lib_path
- exec echo ".TP" >> /tmp/omnimoni.1
- exec echo ".BI $lib_path/omnimoni.big.gif" >> /tmp/omnimoni.1
- exec echo "The large picture shown while OmniMoni parses the configuration file." >> /tmp/omnimoni.1
- exec echo ".TP" >> /tmp/omnimoni.1
- exec echo ".BI $lib_path/omnimoni.small.gif" >> /tmp/omnimoni.1
- exec echo "The small picture shown after OmniMoni is done parsing the configuration file." >> /tmp/omnimoni.1
- } elseif {$pics == "big"} {
- exec echo ".TP" >> /tmp/omnimoni.1
- exec echo ".BI $lib_path/omnimoni.big.gif" >> /tmp/omnimoni.1
- exec echo "The large picture shown while OmniMoni parses the configuration file." >> /tmp/omnimoni.1
- exec install -m 444 pics/omnimoni.big.gif $lib_path
- } elseif {$pics == "small"} {
- exec echo ".TP" >> /tmp/omnimoni.1
- exec echo ".BI $lib_path/omnimoni.small.gif" >> /tmp/omnimoni.1
- exec echo "The small picture shown after OmniMoni is done parsing the configuration file." >> /tmp/omnimoni.1
- exec install -m 444 pics/omnimoni.small.gif $lib_path
- }
- }
- }
- if {$INSTALL} {
- exec cat man/omnimoni.man.part2 >> /tmp/omnimoni.1
- exec install -d -m 755 $man_path/man1
- exec install -m 444 /tmp/omnimoni.1 $man_path/man1
- exec rm -f /tmp/omnimoni /tmp/omnimoni.tcl /tmp/omnimoni.1
- }
- if {$VERBOSE} {
- Blurb "" 0
- Blurb "" 0
- Blurb "Done. You should now be able to use OmniMoni. Don't forget to\
- create a config file. OmniMoni checks for one in ~/.omnimoni by \
- default, or you can specify a different one with the -f \
- argument." 0
- Blurb "" 0
- Blurb "Have fun." 0
- }
-
-